let letter = document.querySelector('p')
let str = "abcdefg";
let curIndex = 0
setInterval(() => {
    fn(curIndex)
    curIndex++
    if (curIndex > str.length - 1) {
        curIndex = 0
    }
},1000)

function fn(index) {
    letter.innerHTML = str.slice(0, index + 1)
    console.log(letter.innerHTML);
}
